package com.example.administrator.yunniuusedcar.adapter;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.TextView;

import com.example.administrator.yunniuusedcar.R;
import com.example.administrator.yunniuusedcar.bean.Brand;
import com.example.administrator.yunniuusedcar.bean.Price;

import java.util.List;

/**
 * Created by Administrator on 2017/12/29 0029.
 */

public class CarBoradAdapter extends BaseAdapter {
    public static int POSITION =0;
    private Context context;
    private List<Brand> datas;
    public CarBoradAdapter(Context context, List<Brand> types) {
        this.context = context;
        this.datas = types;
    }

    @Override
    public int getCount() {
        return datas.size();
    }

    @Override
    public Object getItem(int i) {
        return i;
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        view = LayoutInflater.from(context).inflate(R.layout.select_car_item,null);
        Brand type = datas.get(i);
        TextView name = (TextView) view.findViewById(R.id.name);



        if(i==datas.size()-1){
            name.setText("更多");
        }else{
            name.setText(type.getName());
        }

        if(i== POSITION){
            name.setBackgroundResource(R.drawable.beijing_gridview_selectcar_true);
        }else{
            name.setBackgroundResource(R.drawable.beijing_gridview_selectcar_flase);
            name.setTextColor(Color.BLACK);
        }
        return view;
    }
}
